<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="旧密码">
        <el-input v-model="form.oldPwd" type="password" />
      </el-form-item>
      <el-form-item label="新密码">
        <el-input v-model="form.newPwd" type="password" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">提交</el-button>
        <el-button @click="onCancel">清空</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { changepwd } from '@/api/user'

export default {
  data() {
    return {
      form: {
        oldPwd: '',
        newPwd: ''
      }
    }
  },
  methods: {
    onSubmit() {
      changepwd(this.form).then(response => {
        if(response.code == 20000){
          this.$message({
            message: '修改成功',
            type: 'success'
          })
          this.form = { }
        } else {
          this.$message({
            message: '修改失败',
            type: 'error'
          })
        }
        this.listLoading = false
      })
    },
    onCancel() {
      this.$message('已清空'),
      this.form = { }
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

